const webpack = require('webpack');
const WebpackBar = require('webpackbar');
const webpackNodeExternals = require("webpack-node-externals");

const path = require('path');

module.exports = {
  mode: 'development',
  target: 'node',  //不将node自带的诸如path、fs这类的包打进去
  entry: ['./server/index.js'],
  output: {
    filename: 'server.js',
    path: path.resolve(__dirname, 'dist'),
    publicPath: '/'
  },
  devServer: {
    contentBase: path.resolve(__dirname, 'dist'),
    historyApiFallback: true,
  },
  // resolve: {
  //   extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
  // },
  externals: [webpackNodeExternals()],  // //不将node_modules里面的包打进去
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: [path.resolve(__dirname, 'node_modules')],
        use: {
          loader: 'babel-loader',
        },
      }
    ]
  },
  plugins: [
    new WebpackBar(),
  ],
  stats: {
    modules: false,
    children: false,
    chunks: false,
    chunkModules: false
  },

}
